package com.jozen.smart_toilet_system.adapter;

import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jozen.smart_toilet_system.R;
import com.jozen.smart_toilet_system.bean.CommListBean;

public class CommonAdapter extends BaseQuickAdapter<CommListBean, BaseViewHolder> {

    private int viewType = 0;

    public CommonAdapter(int layoutResId) {
        super(layoutResId);
    }

    //展示的icon类型
    public void setType(int type) {
        viewType = type;
    }

    @Override
    protected void convert(BaseViewHolder helper, CommListBean item) {
        ImageView iv_icon = helper.getView(R.id.iv_icon);

        if (viewType == 0) {
            if (item.getStatus() == 0) {
                iv_icon.setImageResource(R.drawable.ic_toilet_paper_normal);
            } else {
                iv_icon.setImageResource(R.drawable.ic_toilet_paper_empty);
            }
        } else if (viewType == 1) {
            if (item.getStatus() == 0) {
                iv_icon.setImageResource(R.drawable.ic_liquid_soap_normal);
            } else {
                iv_icon.setImageResource(R.drawable.ic_liquid_soap_empty);
            }
        }
    }
}
